/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  dev
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

domain
{
    xMin -4;
    xMax  4;
    zMin -2;
    zMax  2;

    // Number of cells
    zCells  80; // aerofoil to far field
    xUCells 30; // upstream
    xMCells 30; // middle
    xDCells 40; // downstream

    // Mesh grading
    zGrading    40;  // aerofoil to far field
    xUGrading   5;   // towards centre upstream
    leadGrading 0.2; // towards leading edge
    xDGrading   10;  // downstream
}

aerofoil
{
    xLead   0;
    zLead   0;
    xTrail  1;
    zTrail  0;
    xUpper  0.3;
    zUpper  0.06;
    xLower  0.3;
    zLower -0.06;
}

geometry
{
    aerofoil
    {
        type   triSurfaceMesh;
        file   "NACA0012.obj";
    }
    cylinder
    {
        type   searchableCylinder;
        point1 ($:aerofoil.xUpper -1e3 0);
        point2 ($:aerofoil.xUpper  1e3 0);
        radius $:domain.zMax;
    }
}

vertices
(
    project ($aerofoil.xLower -0.1 $domain.zMin) (cylinder)
    ($aerofoil.xTrail -0.1 $domain.zMin)
    ($domain.xMax -0.1 $domain.zMin)

    project ($domain.xMin     -0.1 $aerofoil.zLead) (cylinder)
    project ($aerofoil.xLead  -0.1 $aerofoil.zLead) (aerofoil)
    project ($aerofoil.xTrail -0.1 $aerofoil.zTrail) (aerofoil)
    ($domain.xMax -0.1 $aerofoil.zTrail)

    project ($aerofoil.xLower -0.1 $aerofoil.zLower) (aerofoil)
    project ($aerofoil.xUpper -0.1 $aerofoil.zUpper) (aerofoil)

    project ($aerofoil.xUpper -0.1 $domain.zMax) (aerofoil)
    project ($aerofoil.xTrail -0.1 $domain.zMax) (aerofoil)
    ($domain.xMax -0.1 $domain.zMax)

    project ($aerofoil.xLower  0.1 $domain.zMin) (cylinder)
    ($aerofoil.xTrail  0.1 $domain.zMin)
    ($domain.xMax 0.1 $domain.zMin)

    project ($domain.xMin      0.1 $aerofoil.zLead) (cylinder)
    project ($aerofoil.xLead   0.1 $aerofoil.zLead) (aerofoil)
    project ($aerofoil.xTrail  0.1 $aerofoil.zTrail) (aerofoil)
    ($domain.xMax 0.1 $aerofoil.zTrail)

    project ($aerofoil.xLower  0.1 $aerofoil.zLower) (aerofoil)
    project ($aerofoil.xUpper  0.1 $aerofoil.zUpper) (aerofoil)

    project ($aerofoil.xUpper  0.1 $domain.zMax) (aerofoil)
    project ($aerofoil.xTrail  0.1 $domain.zMax) (aerofoil)
    ($domain.xMax 0.1 $domain.zMax)
);

blocks
(
    hex ( 7 4 16 19 0 3 15 12)
    ($:domain.xUCells 1 $:domain.zCells)
    edgeGrading
    (
        $:domain.leadGrading $:domain.leadGrading $:domain.xUGrading $:domain.xUGrading
        1 1 1 1
        $:domain.zGrading $:domain.zGrading $:domain.zGrading $:domain.zGrading
    )

    hex ( 5 7 19 17 1 0 12 13)
    ($:domain.xMCells 1 $:domain.zCells)
    simpleGrading (1 1 $:domain.zGrading)

    hex ( 17 18 6 5 13 14 2 1)
    ($:domain.xDCells 1 $:domain.zCells)
    simpleGrading ($:domain.xDGrading 1 $:domain.zGrading)

    hex ( 20 16 4 8 21 15 3 9)
    ($:domain.xUCells 1 $:domain.zCells)
    edgeGrading
    (
        $:domain.leadGrading $:domain.leadGrading $:domain.xUGrading $:domain.xUGrading
        1 1 1 1
        $:domain.zGrading $:domain.zGrading $:domain.zGrading $:domain.zGrading
    )

    hex ( 17 20 8 5 22 21 9 10)
    ($:domain.xMCells 1 $:domain.zCells)
    simpleGrading (1 1 $:domain.zGrading)

    hex ( 5 6 18 17 10 11 23 22)
    ($:domain.xDCells 1 $:domain.zCells)
    simpleGrading ($:domain.xDGrading 1 $:domain.zGrading)
);

edges
(

    project 4 7 (aerofoil)
    project 7 5 (aerofoil)
    project 4 8 (aerofoil)
    project 8 5 (aerofoil)

    project 16 19 (aerofoil)
    project 19 17 (aerofoil)
    project 16 20 (aerofoil)
    project 20 17 (aerofoil)

    project 3 0 (cylinder)
    project 3 9 (cylinder)
    project 15 12 (cylinder)
    project 15 21 (cylinder)
);

boundary
(
    aerofoil
    {
        type wall;
        faces
        (
            (4 7 19 16)
            (7 5 17 19)
            (5 8 20 17)
            (8 4 16 20)
        );
    }

    inlet
    {
        type patch;
        inGroups (freestream);
        faces
        (
            (3 0 12 15)
            (0 1 13 12)
            (1 2 14 13)
            (11 10 22 23)
            (10 9 21 22)
            (9 3 15 21)
        );
    }

    outlet
    {
        type patch;
        inGroups (freestream);
        faces
        (
            (2 6 18 14)
            (6 11 23 18)
        );
    }

    back
    {
        type empty;
        faces
        (
            (3 4 7 0)
            (7 5 1 0)
            (5 6 2 1)
            (3 9 8 4)
            (9 10 5 8)
            (10 11 6 5)
        );
    }

    front
    {
        type empty;
        faces
        (
            (15 16 19 12)
            (19 17 13 12)
            (17 18 14 13)
            (15 16 20 21)
            (20 17 22 21)
            (17 18 23 22)
        );
    }
);

// ************************************************************************* //
